#ifndef BLE_MODULE_H
#define BLE_MODULE_H

#include "audio_element.h"
#include "esp_bt_defs.h"
#include "esp_gap_bt_api.h"
#include "esp_peripherals.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#define BT_AUTO_DISCOVERY_TIMEOUT (300) // 30s
typedef enum {
    CMD_INDEX = 0,
    TFN_INDEX,
    TFI_INDEX,
    RF_INDEX,
} BLE_char_list_t;

typedef enum {
    USER_BT_STOP = 0,
    USER_BT_START,
    USER_BT_DISCONNECT,
    USER_BT_CONNECT,
    USER_BT_RECONNECT,
    USER_BT_PAUSE,
    USER_BT_RESUME
} user_bt_cmd_t;

extern audio_element_handle_t bt_stream_reader,raw_read;
extern esp_periph_handle_t bt_periph;

void ble_init(void);
void ble_sendPacket(BLE_char_list_t char_index, uint8_t *data, uint16_t len, bool is_indicate);
void ble_sendFile_notify(char *data, int data_len);

void user_bt_init(void);
void bt_task(void *param);
void user_bt_audio_config(user_bt_cmd_t cmd);
void user_bt_connect(bool is_default_mac, uint8_t remote_addr[6]);
void user_bt_disconnect(void);
void user_bt_discovery_config(bool enable);

#endif // BLE_MODULE_H
